const service = require('./thanksVideoService.js')
var page = 1
var state
Page({
    /**
     * 页面的初始数据
     */
    data: {
      tabs: ["发出感谢", "收到感谢"],
      activeIndex: 0,
      dataSource1: null,
      items1:[],
      dataSource2: null,
      items2: [],
      isLoading:true,
  },
    onLoad: function (options) {
      this.setData({ activeIndex: options.type - 1 })
        this.sendThanks()
      
        this.receiveThanks()
      
      
    },
    sendThanks: function (){
      var that = this
      var parma = {
        type: 0,
        userId: getApp().globalData.userId,
        startPage:0,
        currentUserId: getApp().globalData.userId
      }
      service.requestProducts(parma, function (data) {
        var array = data.items
        that.setData({ dataSource1: data, items1: array, isLoading: false  });
      });
    },
    receiveThanks: function (){
      var that = this
      var parma = {
        type: 2,
        userId: getApp().globalData.userId,
        startPage: 0,
        currentUserId: getApp().globalData.userId
      }
      service.requestProducts(parma, function (data) {
        var array = data.items
        that.setData({ dataSource2: data, items2: array, isLoading:false });
      });
    },

    itemClick: function (e) {

    },
    
    showInfo: function (data) {
      console.log(data)
      wx.navigateTo({
        url: '../../storyInfo/storyInfo?data=' + data,
      })
    },
    showVideo: function (data) {
      console.log(data)
    }

});
